global OldLineNum, OldCharNum, WordsField, Update, ManBold, ManBoldLine, ManBoldField
if ManBold = 1 then
set the textStyle of line ManBoldLine of field ManBoldField to "Plain"
set ManBold to 0
end if
if Update = 0 then
exit
end if
set CharNum to the length of field "Entry"
set height to the textHeight of field WordsField
if (OldCharNum > CharNum) and (field "Entry" <> EMPTY) then
if (OldLineNum = 1) or (char 1 to CharNum of line OldLineNum - 1 of field WordsField <> field "Entry") then
if not NoMoreWords(CharNum, OldLineNum) then
end if
else
UnhiliteLine(OldLineNum)
set OldLineNum to 0
end if
end if
if field "Entry" = EMPTY then
UnhiliteLine(OldLineNum)
set OldLineNum to 0
end if
if CharNum = 1 then
BSuspend(21, 22)
if char 1 of field "Entry" <= "l" then
go("Find1")
end if
if char 1 of field "Entry" >= "m" then
go("Find2")
end if
end if
if field "Entry" <> EMPTY then
set LineNum to PickLine(OldLineNum)
if LineNum <> OldLineNum then
UnhiliteLine(OldLineNum)
if LineNum <> 0 then
HiliteLine(LineNum)
end if
end if
if OldLineNum <> LineNum then
if LineNum <> 0 then
set the scrollTop of member WordsField to (LineNum - 1) * height
end if
end if
set OldLineNum to LineNum
set OldCharNum to CharNum
else
set the scrollTop of member WordsField to 0
end if
end
on FindEnterWord
global OldLineNum, WordsField, Update
if the key = RETURN then
if field "Entry" <> EMPTY then
if Update = 1 then
DisplayResults(Search(line OldLineNum of field WordsField))
else
DisplayResults(Search(field "Entry"))
end if
else
beep()
end if
dontPassEvent()
end if
end
on NoMoreWords CharNum, LineNum
global WordsField
set Temp to 0
set LineNum to LineNum + 1
set len to the length of field "Entry"
if char 1 to len of line LineNum of field WordsField <> field "Entry" then
set Temp to 1
else
set Temp to 0
end if
return Temp
end
on PickLine StartLine
global PickLineResult, WordsField
if StartLine = 0 then
set StartLine to 1
end if
set len to the length of field "Entry"
if char 1 to len of line StartLine of field WordsField = field "Entry" then
return StartLine
end if
set PickLineResult to 0
set Num to the number of lines in field WordsField
PickLineHelp(field "Entry", 1, Num)
repeat while (char 1 to len of line PickLineResult of field WordsField > field "Entry") or (char 1 to len of line PickLineResult of field WordsField = field "Entry")
set Temp to PickLineResult
set PickLineResult to PickLineResult - 10
if Temp <= 1 then
exit repeat
end if
end repeat
set PickLineResult to Temp
set Temp2 to PickLineResult
repeat while char 1 to len of line PickLineResult of field WordsField = field "Entry"
set Temp to PickLineResult
set PickLineResult to PickLineResult - 1
if Temp <= 1 then
exit repeat
end if
end repeat
return Temp
end
on PickLineHelp key, min, max
global PickLineResult, WordsField
set len to the length of field "Entry"
set Mid to ((max - min) / 2) + min
if char 1 to len of line Mid of field WordsField = key then
set PickLineResult to Mid
exit
end if
if char 1 to len of line min of field WordsField = key then
set PickLineResult to min
exit
end if
if char 1 to len of line max of field WordsField = key then
set PickLineResult to max
exit
end if
if (min + 1) = max then
set PickLineResult to 0
exit
end if
if char 1 to len of line Mid of field WordsField > key then
PickLineHelp(key, min, Mid)
exit
end if
if char 1 to len of line Mid of field WordsField < key then
PickLineHelp(key, Mid, max)
exit
end if
end
on ChangeWord CharNum, LineNum
global WordsField
set ReturnVal to 0
if char CharNum of line LineNum of field WordsField <> char CharNum of field "Entry" then
set ReturnVal to 1
end if
return ReturnVal
end
on HiliteLine LineNum
global WordsField
set the textStyle of line LineNum of field WordsField to "Bold"
end
on UnhiliteLine LineNum
global WordsField
set the textStyle of line LineNum of field WordsField to "Plain"
end
on Search key
global SearchResult, SearchIndex
set SearchResult to 0
set Num to the number of lines in SearchIndex
SearchHelp(key, 1, Num)
if value(SearchResult) = 0 then
beep()
end if
return value(SearchResult)
end
on SearchHelp key, min, max
global SearchResult, SearchIndex
set Mid to ((max - min) / 2) + min
if item 1 of line Mid of SearchIndex = key then
set SearchResult to Mid
exit
end if
if item 1 of line max of SearchIndex = key then
set SearchResult to max
exit
end if
if item 1 of line min of SearchIndex = key then
set SearchResult to min
exit
end if
if (min + 1) = max then
exit
end if
if item 1 of line Mid of SearchIndex > key then
SearchHelp(key, min, Mid)
exit
end if
if item 1 of line Mid of SearchIndex < key then
SearchHelp(key, Mid, max)
exit
end if
end
on DisplayResults LineNum
global SearchIndex
if LineNum = 0 then
put EMPTY into field "Results"
exit
end if
set lineCount to 1
set Temp to EMPTY
set ItemLine to line LineNum of SearchIndex
repeat with count = 2 to the number of items in ItemLine
put line value(item count of ItemLine) of field "Scientist Order" into line lineCount of Temp
set lineCount to lineCount + 1
end repeat
put Temp into field "Results"
set the scrollTop of member "Results" to 0
end
on PrepFind
global SearchIndex
set SearchIndex to field "Search1"
set SearchIndex to SearchIndex & RETURN & field "Search2"
set the textHeight of field "Words1" to 14
set the textHeight of field "Words2" to 14
end
on FixIndexList fname
set count to 1
repeat while line count of field fname <> EMPTY
put count
set Current to item 1 of line count of field fname
if item 1 of line count + 1 of field fname = Current then
repeat with Count2 = 2 to the number of items in line count + 1 of field fname
set Temp to 0
repeat with Count3 = 2 to the number of items in line count of field fname
if item Count2 of line count + 1 of field fname = item Count3 of line count of field fname then
set Temp to 1
end if
end repeat
if Temp = 0 then
put item Count2 of line count + 1 of field fname into item the number of items in line count of field fname + 1 of line count of field fname
end if
end repeat
delete line count + 1 of field fname
next repeat
end if
set count to count + 1
end repeat
beep()
beep()
beep()
end
on extract
repeat with count = 1 to 146
put the name of cast (count + 300) into line count of field "Scientist Order"